cc.Class({
    extends: cc.Component,

    properties: {
        sprite1: cc.Sprite,
        sprite2: cc.Sprite,
        sprite3: cc.Sprite,
    },

    init(data) {
        this.sprite1.spriteFrame = null;
        this.sprite2.spriteFrame = null;
        this.sprite3.spriteFrame = null;

        let knotId = data.substring(0, 2);
        let angleId = data.substring(2, 3);

        this._setKnotTexture(knotId);
        this._setAngle(angleId);
    },

    _setKnotTexture(knotId) {
        let name;
        let sprite;
        if (knotId == 10) {
            name = 'red1';
            sprite = this.sprite1;
        } else if (knotId == 11) {
            name = 'red2';
            sprite = this.sprite2;
        } else if (knotId == 12) {
            name = 'red3';
            sprite = this.sprite3;
        } else if (knotId == 13) {
            name = 'blue1';
            sprite = this.sprite1;
        } else if (knotId == 14) {
            name = 'blue2';
            sprite = this.sprite2;
        } else if (knotId == 15) {
            name = 'blue3';
            sprite = this.sprite3;
        } else if (knotId == 16) {
            name = 'green1';
            sprite = this.sprite1;
        } else if (knotId == 17) {
            name = 'green2';
            sprite = this.sprite2;
        } else if (knotId == 18) {
            name = 'green3';
            sprite = this.sprite3;
        } else if (knotId == 19) {
            name = 'yellow1';
            sprite = this.sprite1;
        } else if (knotId == 20) {
            name = 'yellow2';
            sprite = this.sprite2;
        } else if (knotId == 21) {
            name = 'yellow3';
            sprite = this.sprite3;
        }
        let url = 'textures/' + name;
        G.common.setSpriteFrame(sprite, url)
    },

    _setAngle(angleId) {
        this.node.angle = angleId * -60;
    },


});
